//
//  MyOrderNet.m
//  beautyLamp
//
//  Created by Tam Kwok To Michael on 2017/9/12.
//  Copyright © 2017年 Tam Kwok To Michael. All rights reserved.
//

#import "MyOrderNet.h"
#import "BLHeader.h"
#import "BasicNetManager.h"
#import "BLOrder.h"
#import <YYModel.h>

@implementation MyOrderNet

+ (void)getOrderList:(NSInteger) state index:(NSInteger)pageIndex completer:(void(^)(id resultObject, NSError *error))completer {
    BasicNetManager *manager = [BasicNetManager share];
    NSString *tel = [[NSUserDefaults standardUserDefaults] objectForKey:USERTEL];
    NSDictionary *param = @{@"orderState":[NSString stringWithFormat:@"%li",state],@"pageIndex":[NSString stringWithFormat:@"%li",pageIndex], @"userTel" : tel,@"pageNumber":@"15"};
    [manager postURL:ORDER_LIST param:param completer:^(id result, NSError *error) {
        NSArray *resultArray = result;
        NSMutableArray *orders = [[NSMutableArray alloc] init];
        for (int i = 0; i < resultArray.count; i++) {
            BLOrder *order = [BLOrder yy_modelWithJSON:resultArray[i]];
            [orders addObject:order];
        }
        if (completer) {
            completer (orders, error);
        }
    }];
    
}

@end
